﻿using System;
using System.Collections;
using System.Configuration;
using System.Data;
using System.Linq;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.HtmlControls;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Xml.Linq;

namespace EcSalseManage.EcSalse
{
    public partial class GetGridViewByConditionForm : System.Web.UI.Page
    {
    //    protected void Page_Load(object sender, EventArgs e)
    //    {
           
    //            String flag = Request.QueryString["flag"];
    //            if (Request.QueryString["Mainid"] != null)
    //            {
    //                Session["Mainid"] = Request.QueryString["Mainid"].ToString();
    //            }
    //            if (flag == "load")
    //            {
    //                DataBind();
    //            }
    //            else if (flag == "update")
    //            {
    //                DataAccess.Operate.DA_Report_Commission_Operate Report_Commission_Operate = new DataAccess.Operate.DA_Report_Commission_Operate();
    //                DataEntity.T_Report_Commission Report_Commission = new DataEntity.T_Report_Commission();
    //                Report_Commission.Report_Commission_InvoiceNO = Request.QueryString["Report_Commission_InvoiceNO"].ToString();
    //                Report_Commission.Report_Commission_Money = Convert.ToDecimal(Request.QueryString["Report_Commission_Money"]);
    //                Report_Commission.Report_Commission_MainID = new Guid(Session["Mainid"].ToString());
    //                Report_Commission.Report_Commission_ID =new Guid(Request.QueryString["id"].ToString());
    //                Report_Commission.Report_Commission_ExchangeTypeID = 1;
    //                Report_Commission_Operate.Update(Report_Commission);
    //                DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 2, new Guid(Session["Mainid"].ToString()), 2);
    //                DataBind();
    //            }
    //            else if (flag == "add")
    //            {
    //                DataAccess.Operate.DA_Report_Commission_Operate Report_Commission_Operate = new DataAccess.Operate.DA_Report_Commission_Operate();
    //                DataEntity.T_Report_Commission Report_Commission = new DataEntity.T_Report_Commission();
    //                Report_Commission.Report_Commission_MainID = new Guid(Session["Mainid"].ToString());
    //                Report_Commission.Report_Commission_InvoiceNO = Request.QueryString["Report_Commission_InvoiceNO"];
    //                Report_Commission.Report_Commission_Money =Convert.ToDecimal(Request.QueryString["Report_Commission_Money"]);
    //                Report_Commission.Report_Commission_ExchangeTypeID = 1;
    //                Report_Commission_Operate.Insert(Report_Commission);
    //                DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 2,new Guid(Session["Mainid"].ToString()), 1);
    //                DataBind();
    //            }
    //            else if (flag == "delete")
    //            {
    //                DataAccess.Operate.DA_Report_Commission_Operate Report_Commission_Operate = new DataAccess.Operate.DA_Report_Commission_Operate();
    //                Report_Commission_Operate.Delete( Request.QueryString["id"]);
    //                DataAccess.Multi.System_Multi.addLog(Session["EmployeeID"].ToString(), Session["EmployeeName"].ToString(), 2, new Guid(Session["Mainid"].ToString()), 3);
    //                DataBind();
    //            }
       
    //    }

    //    public void DataBind()
    //    {
    //        DataAccess.Operate.DA_Report_Commission_Inherit Report_Commission_Inherit = new DataAccess.Operate.DA_Report_Commission_Inherit();
    //        DataSet ds = Report_Commission_Inherit.FindByMainID(Session["Mainid"].ToString());
    //        this.gvwReport_Commission.DataSource = ds.Tables[0];
    //        this.gvwReport_Commission.DataBind();
    //    }


    //    protected void gvwReport_Commission_PreRender(object sender, EventArgs e)
    //    {
    //        if (gvwReport_Commission.Rows.Count == 0)
    //        {
    //            renderEmptyGridView(gvwReport_Commission, "Report_Commission_ID,Report_Commission_InvoiceNO,Report_Commission_Money");
    //        }
    //    }

    //    /// <summary>
    //    ///  让GridView在无数据时显示
    //    /// </summary>
    //    /// <param name="EmptyGridView"></param>
    //    /// <param name="FieldNames"></param>
    //    public static void renderEmptyGridView(GridView EmptyGridView, string FieldNames)
    //    {
    //        //將GridView變成只有Header和Footer列，以及被隱藏的空白資料列
    //        DataTable dTable = new DataTable();
    //        char[] delimiterChars = { ',' };
    //        string[] colName = FieldNames.Split(delimiterChars);
    //        foreach (string myCol in colName)
    //        {
    //            DataColumn dColumn = new DataColumn(myCol.Trim());
    //            dTable.Columns.Add(dColumn);
    //        }
    //        DataRow dRow = dTable.NewRow();

    //        foreach (string myCol in colName)
    //        {
    //            dRow[myCol.Trim()] = DBNull.Value;
    //        }
    //        dTable.Rows.Add(dRow);

    //        EmptyGridView.DataSourceID = null;
    //        EmptyGridView.DataSource = dTable;
    //        EmptyGridView.DataBind();
    //        EmptyGridView.Rows[0].Visible = false;


    //    }

    //    protected void gvwReport_Commission_RowDeleting(object sender, GridViewDeleteEventArgs e)
    //    {
    //        object id = this.gvwReport_Commission.DataKeys[e.RowIndex].Value;
    //        DataAccess.Operate.DA_Report_Commission_Operate Report_Commission_Operate = new DataAccess.Operate.DA_Report_Commission_Operate();
    //        if (Report_Commission_Operate.Delete(id))
    //        {
    //            Response.Write("<script>alert('删除成功！')</script>");
    //            DataBind();
    //        }
    //        else
    //        {
    //            Response.Write("<script>alert('删除失败！')</script>");
    //        }
    //    }

    //    protected void gvwReport_Commission_RowEditing(object sender, GridViewEditEventArgs e)
    //    {
    //        this.gvwReport_Commission.EditIndex = e.NewEditIndex;
    //        DataBind();
    //    }

    //    protected void gvwReport_Commission_RowCommand(object sender, GridViewCommandEventArgs e)
    //    {

    //    }

    //    protected void gvwReport_Commission_RowDataBound(object sender, GridViewRowEventArgs e)
    //    {

    //    }

    //    protected void gvwReport_Commission_RowCancelingEdit(object sender, GridViewCancelEditEventArgs e)
    //    {
    //        this.gvwReport_Commission.EditIndex = -1;
    //        DataBind();
    //    }

    //    protected void gvwReport_Commission_RowUpdating(object sender, GridViewUpdateEventArgs e)
    //    {
    //        object id = this.gvwReport_Commission.DataKeys[e.RowIndex].Value;
    //        DataEntity.T_Report_Commission Report_Commission = new DataEntity.T_Report_Commission();
    //        Report_Commission.Report_Commission_ID = new Guid(id.ToString());
    //        Report_Commission.Report_Commission_ExchangeTypeID = 1;
    //        Report_Commission.Report_Commission_MainID = new Guid(Session["id"].ToString());
    //        Report_Commission.Report_Commission_InvoiceNO = (gvwReport_Commission.Rows[e.RowIndex].FindControl("txtReport_Commission_InvoiceNO") as TextBox).Text;
    //        Report_Commission.Report_Commission_Money = Convert.ToDecimal((gvwReport_Commission.Rows[e.RowIndex].FindControl("txtReport_Commission_Money") as TextBox).Text);
    //        DataAccess.Operate.DA_Report_Commission_Operate Report_Commission_Operate = new DataAccess.Operate.DA_Report_Commission_Operate();
    //        if (Report_Commission_Operate.Update(Report_Commission))
    //        {
    //            Response.Write("<script>alert('修改成功！')</script>");
    //            DataBind();
    //        }
    //        else
    //        {
    //            Response.Write("<script>alert('修改失败！')</script>");
    //        }

    //    }
    }
}
